/*
 * Copyright (c) 2011 Team A CS2340. All rights reserved.
 */
package edu.gatech.teama.doctorsoffice.model;

import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Prescription.java: object represents an entire prescription 
 * @author Team A
 * @version 1.0
 *
 */
public class Prescription extends AbstractModelObject {

	/**
	 * drug name
	 */
	private final String drugName;
	
	/**
	 * number of pills prescribed
	 */
	private final int numberOfPills;
	
	/**
	 * how often pills are taken
	 */
	private final int timesPerDay;
	
	/**
	 * instructions on how to take the pills and side effects
	 */
	private final String otherInstructions;
	
	/**
	 * Logger for all <code>PatientInstructions</code> instances.
	 */
	private static final Logger LOGGER =
		Logger.getLogger("edu.gatech.teama.doctorsoffice.server.ClientMessageHandler");

	static {
        FileHandler fh = null;
        try {
            fh = new FileHandler("application.log");
        } catch (SecurityException e) {
            LOGGER.log(Level.SEVERE, "Security Exception creating the logger " +
            		"file handler");
            e.printStackTrace();
        } catch (IOException e) {
            LOGGER.log(Level.SEVERE, "IO Exception creating the logger file handler");
            e.printStackTrace();
        }

        LOGGER.addHandler(fh);
        LOGGER.setLevel(Level.ALL);
    }
	
	/**
	 * Complete prescription 
	 * @param numberOfPills
	 * @param timesPerDay
	 * @param otherInstructions
	 * @param drugName
	 */
	public Prescription(String drugName, int numberOfPills, int timesPerDay,
			String otherInstructions) {
		this.drugName = drugName;
		this.numberOfPills = numberOfPills;
		this.timesPerDay = timesPerDay;
		this.otherInstructions = otherInstructions;
		LOGGER.info("Prescription: Take " + numberOfPills + " " + drugName + ", " 
			+ timesPerDay + " times per day. Additional instructions: "
			+ otherInstructions);
	}
	
	/**
	 * Returns statement about complete prescription
	 * @return "prescription description"
	 */
	public String toString() {
		return "Take " + numberOfPills + " " + drugName + ", " + timesPerDay 
			+ " times per day. Additional instructions: " + otherInstructions;
	}

	/**
	 * get drug name
	 * @return getDrugName
	 */
	public String getDrugName() {
		return drugName;
	}

	/**
	 * get number of pills
	 * @return numberOfPils
	 */
	public int getNumberOfPills() {
		return numberOfPills;
	}

	/**
	 * get times perday
	 * @return timesPerDay
	 */
	public int getTimesPerDay() {
		return timesPerDay;
	}

	/**
	 * get other instructions
	 * @return otherInstructions
	 */
	public String getOtherInstructions() {
		return otherInstructions;
	}
}
